package com.fyt.ZhongYaoApp.Controller;

import com.fyt.ZhongYaoApp.pojo.Collection;
import com.fyt.ZhongYaoApp.pojo.Essay;
import com.fyt.ZhongYaoApp.pojo.Result;
import com.fyt.ZhongYaoApp.pojo.vo.EssayCollectionVO;
import com.fyt.ZhongYaoApp.pojo.vo.ZYCollectionVO;
import com.fyt.ZhongYaoApp.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/collection")
public class CollectionController {

    @Autowired
    private CollectionService collectionService;

    /**
     * 添加收藏
     * @param collection
     * @return
     */
    @PostMapping("/add")
    public Result addCollection(@RequestBody Collection collection) {

        if(collectionService.addCollection(collection)){
            return Result.success("收藏成功");
        }else{
            return Result.success("取消收藏");
        }


    }

    /**
     * 查询收藏文章列表
     * @return
     */
    @PostMapping("/essaylist")
    public Result<List<EssayCollectionVO>> essay() {

        List<EssayCollectionVO> list = collectionService.essayList();
        return Result.success(list);
    }

    @PostMapping("/zylist")
    public Result<List<ZYCollectionVO>> zyCollection() {

        List<ZYCollectionVO> list = collectionService.zyList();
        return Result.success(list);
    }


}
